package la.iok.hzsvn.lewin.movie.cloud.controller;

import la.iok.hzsvn.lewin.movie.cloud.service.RoomService;
import la.iok.hzsvn.lewin.movie.core.model.RoomVo;
import la.iok.hzsvn.share.response.ListDataResponse;
import la.iok.hzsvn.share.response.SingleDataResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("internal-api/rooms")
public class RoomInternalController {
    private final RoomService roomService;

    public RoomInternalController(RoomService roomService) {
        this.roomService = roomService;
    }

    @GetMapping("{id}")
    public SingleDataResponse<RoomVo> roomInfo(@PathVariable Long id){
        return new SingleDataResponse<>(roomService.po2vo(roomService.select(id)));
    }

    @GetMapping
    public ListDataResponse<RoomVo> roomInfo(Long[] ids){
        return new ListDataResponse<>(roomService.rooms(ids));
    }

    /**
     * 查询多个店铺的所有房间
     * @param orgUnitIds 店铺列表
     * @return 店铺的房间列表
     */
    @GetMapping("shopRooms")
    public ListDataResponse<RoomVo> shopRooms(Long[] orgUnitIds){
        return new ListDataResponse<>(roomService.shopRooms(orgUnitIds));
    }
}
